//
//  HomeTableViewCell.m
//  pocketNews
//
//  Created by DS on 2018/10/26.
//  Copyright © 2018年 徐双. All rights reserved.
//

#import "HomeTableViewCell.h"


@interface HomeTableViewCell()


Strong UIImageView * picImageView;

Strong UILabel * contentLabel;

Strong UILabel * writerLabel;

Strong UILabel * timeLabel;

@end

@implementation HomeTableViewCell

- (instancetype)initWithCellIdentifier:(NSString *)cellID{
    
    if (self = [super initWithCellIdentifier:cellID]) {
        
        self.selectionStyle = UITableViewCellSelectionStyleNone;
        
        
        _picImageView = [UIImageView addImgWithImage:@"yinxingyanjing"];
        _picImageView.layer.masksToBounds = YES;
        
        
        _contentLabel = [UILabel addLableFont:16 WithColor:getColor(@"111111")];
        _contentLabel.numberOfLines = 0;
        _contentLabel.text = @"1233";
        
        _writerLabel = [UILabel addLableFont:12 WithColor:getColor(@"1E7CD2")];
        _writerLabel.text = @"rr";
        
        _timeLabel = [UILabel addLableFont:12 WithColor:getColor(@"696969")];
        _timeLabel.text = @"jfif";
        
        [self sd_addSubviews:@[self.picImageView,self.contentLabel,self.writerLabel,self.timeLabel]];
        
        [self layOutFrame];
        
    }
    
    return self;
    
}



- (void)layOutFrame{
    
    
    ws(self)
    
    [self.picImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(UNIT_WIDTH(10));
        make.left.mas_equalTo(UNIT_WIDTH(10));
        make.bottom.mas_equalTo(UNIT_WIDTH(-10));
        make.width.mas_equalTo(UNIT_WIDTH(100));
    }];
    
    
    [self.contentLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(weakself.picImageView.mas_top).offset(UNIT_WIDTH(10));
        make.right.mas_equalTo(UNIT_WIDTH(-10));
        make.left.mas_equalTo(weakself.picImageView.mas_right).offset(UNIT_WIDTH(10));
    }];
    
    [self.writerLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.left.mas_equalTo(weakself.picImageView.mas_right).offset(UNIT_WIDTH(10));
        make.bottom.mas_equalTo(weakself.picImageView.mas_bottom).offset(UNIT_WIDTH(-10));
        make.height.mas_equalTo(UNIT_HEIGHT(30));
        
    }];
    
    [self.timeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.left.mas_equalTo(weakself.writerLabel.mas_right).offset(UNIT_WIDTH(10));
        make.centerY.mas_equalTo(weakself.writerLabel.mas_centerY);
        make.height.mas_equalTo(UNIT_HEIGHT(30));
        
    }];
    
    
    
}

- (void)setModel:(HomeSonModel *)model{
    
    _model = model;
    
     NSURL * url = [NSURL URLWithString:model.thumbnail_pic_s];
    
     [self.picImageView  sd_setImageWithURL:url placeholderImage:[UIImage imageNamed:@"pic_32"]];
    
    self.contentLabel.text = model.title;
    
    self.writerLabel.text = model.author_name;
    
    self.timeLabel.text = model.date;
    
}

@end
